package com.tanhua.dubbo.api.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.api.BlackListApi;
import com.tanhua.dubbo.mapper.BlackListMapper;
import com.tanhua.dubbo.pojo.BlackList;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author zmy  at 2021/6/21 20:15
 */

@DubboService(version = "1.0.0")
public class BlackListApiImpl implements BlackListApi {

    @Autowired
    private BlackListMapper blackListMapper;


    @Override
    public List<BlackList> queryBlackList(Long userId, Integer page, Integer pageSize) {
        Page pages = new Page(page, pageSize);
        QueryWrapper<BlackList> blackListQueryWrapper = new QueryWrapper<>();
        blackListQueryWrapper.eq("user_id", userId);

        return this.blackListMapper.selectList(blackListQueryWrapper);


    }

    /**
     * 删除 黑名单
     *
     * @param userId
     * @param uid
     * @return
     */
    @Override
    public Object deleteBlackUser(Long userId, String uid) {

        QueryWrapper<BlackList> blackListQueryWrapper = new QueryWrapper<>();
        blackListQueryWrapper.eq("user_id", userId).eq("black_user_id", uid);

        return this.blackListMapper.delete(blackListQueryWrapper);
    }
}
